package GUI.Season;

import java.awt.Color;
import java.awt.Component;
import java.util.Vector;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class SeasonCellRenderer extends DefaultTableCellRenderer 
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	@Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
	{
		if (value instanceof String) 
		{
			SeasonTableModel stm = (SeasonTableModel) table.getModel();
            Vector<String> selectedEpisode = stm.getSelectedEpisode();
            Vector<String> downloadedEpisode = stm.getDownloadedEpisodes();
            row = table.convertRowIndexToModel(row);
		
			if (selectedEpisode.contains(value))
			{
				setForeground(Color.BLUE);
			}
			else if(downloadedEpisode.contains(value))
			{
				setForeground(Color.GRAY);
			}
			else 
			{
			    setForeground(null);
			}
			return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        } 
		else 
		{
            setForeground(null);
            return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        }
	}
}
